package com.gerenboke.controller;

import com.gerenboke.domain.ResponseResult;
import com.gerenboke.domain.dto.RoleDto;
import com.gerenboke.domain.dto.RoleSaveDto;
import com.gerenboke.domain.dto.RoleUpdateDto;
import com.gerenboke.service.RoleService;
import org.apache.commons.math3.distribution.LogNormalDistribution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("system/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public ResponseResult RoleList(Long pageNum,Long pageSize,String roleName,String status){
        return roleService.RoleList(pageNum,pageSize,roleName,status);
    }

    @PutMapping("changeStatus")
    public ResponseResult updateRole(@RequestBody RoleDto roleDto){
        return roleService.updateRole(roleDto);
    }

    @PostMapping("")
    public ResponseResult insertRole(@RequestBody RoleSaveDto roleSaveDto){
        return roleService.insertRole(roleSaveDto);
    }

    @GetMapping("/{id}")
    public ResponseResult selectRole(@PathVariable Long id){
        return roleService.selectRole(id);
    }

    @PutMapping
    public ResponseResult updateRole(@RequestBody RoleUpdateDto roleUpdateDto) {
        return roleService.updateRoleMenu(roleUpdateDto);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteRole(@PathVariable String id) {
        return roleService.deleteRole(id);
    }

    @GetMapping("listAllRole")
    public ResponseResult listAllRole(){
        return roleService.listAllRole();
    }
}
